package biz.obake.team.touchprotector.g;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.c;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class a {

    /* renamed from: a  reason: collision with root package name */
    private static final Map<String, String> f1706a = new C0080a();

    /* renamed from: biz.obake.team.touchprotector.g.a$a  reason: collision with other inner class name */
    static class C0080a extends HashMap<String, String> {
        C0080a() {
            put("show_notices_message", c.w(R.bool.notice_message_default));
            put("lock_shake", "false");
            put("unlock_shake", "false");
            put("shake_sensitivity", "2.0");
            put("shake_sensitivity_max", "4.0");
            put("lock_proximity", "false");
            put("unlock_proximity", "false");
            put("unlock_proximity_uncovered", "false");
            put("unlock_proximity_uncovered_force", "false");
            put("proximity_sensitivity", "500");
            put("proximity_sensitivity_uncovered", "500");
            put("proximity_distance", "auto");
            put("proximity_false_testing", "disabled");
            put("proximity_light_threshold", "disabled");
            put("lock_upside_down", "false");
            put("unlock_right_side_up", "false");
            put("upside_down_sensitivity", "-40");
            put("right_side_up_sensitivity", "30");
            put("unlock_volup", "true");
            put("unlock_volup_long", "false");
            put("unlock_volup_twice", "false");
            put("unlock_voldown", "true");
            put("unlock_voldown_long", "false");
            put("unlock_voldown_twice", "false");
            put("unlock_camera", "false");
            put("unlock_camera_long", "false");
            put("unlock_back", "false");
            put("unlock_back_long", "false");
            put("lock_frame_design", "preset:1");
            put("lock_frame_opacity", "100");
            put("backlight", "-1");
            put("full_screen", "false");
            put("show_notification_drawer", "false");
            put("show_navigation_bar", "false");
            put("fix_orientation", "false");
            put("prevent_sleep", "false");
            put("block_volume_keys", "false");
            put("vibrate_length", "75");
            put("action_buttons", "sensor_settings");
            put("notif_lock_delay", "0");
            put("qstile_settings", "true");
            put("qstile_lock", "true");
            put("qstile_sensor", "true");
            put("no_lock_landscape", "false");
            put("five_touches_action", "toast");
            put("unlock_on_screen_off", "false");
            put("lock_on_screen_off", "false");
            put("unlock_on_call", "true");
            put("unlock_usb", "true");
            put("no_lock_usb", "false");
            put("lock_volup_twice", "false");
            put("lock_voldown_twice", "false");
            put("toggle_sensor_volupdown", "false");
            put("pin", "");
            put("require_pin", "false");
            put("require_fingerprint", "false");
            put("lock_sound", "");
            put("unlock_sound", "");
            put("backlight_gesture", "false");
            put("backlight_gesture_panel", "white");
            put("unlockable_lock_screen_now", "false");
            put("tasker", "false");
            put("auto_start", "true");
            put("lock_screen_now", "false");
            put("version_code", "0");
            put("first_version_code", "0");
        }
    }

    public static boolean a(String str) {
        return i().contains(str);
    }

    private static boolean b(String str) {
        return "true".equals(f1706a.get(str));
    }

    private static int c(String str) {
        return Integer.parseInt(f1706a.get(str));
    }

    private static String d(String str) {
        return f1706a.get(str);
    }

    public static String e() {
        StringBuilder sb = new StringBuilder();
        Map<String, ?> all = i().getAll();
        ArrayList arrayList = new ArrayList(all.keySet());
        Collections.sort(arrayList);
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            String str = (String) it.next();
            if (str != null) {
                boolean startsWith = str.startsWith("apps_");
                boolean startsWith2 = str.startsWith("notice_");
                boolean containsKey = f1706a.containsKey(str);
                if (startsWith || startsWith2 || containsKey) {
                    String obj = all.get(str).toString();
                    if (str.equals("pin")) {
                        obj = "********";
                    }
                    sb.append(str + ": " + obj + "\n");
                }
            }
        }
        return sb.toString();
    }

    public static void f() {
        int l = c.l();
        if (j("first_version_code") == 0) {
            q("first_version_code", l);
            q("version_code", l);
        } else if (j("version_code") < l) {
            s();
            t();
            u();
            v();
            w();
            o();
            q("version_code", l);
        }
    }

    public static boolean g(String str) {
        return h(str, b(str));
    }

    private static boolean h(String str, boolean z) {
        try {
            return i().getBoolean(str, z);
        } catch (ClassCastException unused) {
            return z;
        }
    }

    public static SharedPreferences i() {
        return PreferenceManager.getDefaultSharedPreferences(biz.obake.team.android.a.a());
    }

    public static int j(String str) {
        return k(str, c(str));
    }

    private static int k(String str, int i) {
        try {
            return i().getInt(str, i);
        } catch (ClassCastException unused) {
            return i;
        }
    }

    public static String l(String str) {
        return m(str, d(str));
    }

    private static String m(String str, String str2) {
        try {
            return i().getString(str, str2);
        } catch (ClassCastException unused) {
            return str2;
        }
    }

    public static void n(String str) {
        i().edit().remove(str).commit();
    }

    public static void o() {
        Iterator it = new ArrayList(i().getAll().keySet()).iterator();
        while (it.hasNext()) {
            String str = (String) it.next();
            if (!f1706a.containsKey(str) && !str.startsWith("notice_") && !str.startsWith("apps_")) {
                n(str);
            }
        }
    }

    public static void p(String str, boolean z) {
        i().edit().putBoolean(str, z).commit();
    }

    public static void q(String str, int i) {
        i().edit().putInt(str, i).commit();
    }

    public static void r(String str, String str2) {
        i().edit().putString(str, str2).commit();
    }

    public static void s() {
        int j;
        if (j("version_code") < 94 && (j = j("upside_down_sensitivity")) > 0) {
            q("upside_down_sensitivity", -j);
        }
    }

    public static void t() {
        if (j("version_code") < 109) {
            Iterator it = new ArrayList(i().getAll().keySet()).iterator();
            while (it.hasNext()) {
                String str = (String) it.next();
                if (str.startsWith("notice_closed_")) {
                    String substring = str.substring(14);
                    p("notice_" + substring + "_closed", true);
                    n(str);
                }
            }
        }
    }

    public static void u() {
        if (j("version_code") < 117) {
            String m = m("require_pin", "");
            boolean z = !"".equals(m);
            if (g("require_fingerprint")) {
                z = false;
            }
            n("require_pin");
            p("require_pin", z);
            r("pin", m);
        }
    }

    public static void v() {
        if (j("version_code") < 147) {
            n("shake_sensitivity");
        }
    }

    public static void w() {
        if (j("version_code") < 163) {
            p("prevent_sleep", true ^ h("sleep", true));
            n("sleep");
        }
    }
}
